﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VideoLibrary;

namespace MyVideo
{
    public partial class RecordSound : UserControl
    {
        public RecordSound()
        {
            InitializeComponent();
        }
        Media media;
        int seconds = 0;
        private void buttonX1_Click(object sender, EventArgs e)
        {
            media = new Media();
            //var a = media.PlayMedia(@"E:\Class(续)\MVC2.0\[ASP.NET.MVC2.中文教程].WebCast20100902_Video\WebCast20100902_Video.wmv", pictureBox1.Handle);
            if (media.StartRecordSound())
            {
                seconds = 0;
                timer1.Enabled = true;
            }
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            if (media.StopRecordSound(textBoxX1.Text))
            {
                timer1.Enabled = false;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            ++seconds;
            labelX5.Text = media.GetTimeStringBySeconds(seconds);
        }

        private void RecordSound_Load(object sender, EventArgs e)
        {
            textBoxX1.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\record.wav";
        }

        private void buttonX3_Click(object sender, EventArgs e)
        {
            media = new Media(textBoxX1.Text);
            media.PlayMedia();
        }
        protected override void OnResize(EventArgs e)
        {
            panelEx1.Location = new Point((this.Width - panelEx1.Width - 80) / 2, (this.Height - panelEx1.Height - 80) / 2);
            base.OnResize(e);
        }
    }
}
